#include<iostream>
#include<memory>
#include<future>
#include<thread>

using namespace std;

int Add(int num1, int num2) {
    std::cout << "into add!\n";
    return num1 + num2;
}

int main()
{
    //封装任务
    auto task=make_shared<packaged_task<int(int,int)>>(Add);

    //获取任务吧
    future<int> res=task->get_future();
    cout<<"---------------\n";
    thread t([task](){
        (*task)(11,2);
    });
    
    std::cout << res.get() << std::endl;
    t.join();
    return 0;

}